import { defHttp } from '/@/utils/http/axios';
import { ApiCommon } from '../common';

const {
  CUSTOMER_ADMIN_API,
  ADMIN_USER_DICT_API,
  BILLING_ADMIN_API,
  SYS_ADMIN_API,
} = ApiCommon;

enum Api {
  CONTACT_list = '/contact/list/query', //查询联系人
  COMPANY_LIST = '/company/list/query', //查询企业
  WATER_SERVICE = '/integrated-business/approval/water/service', //过户
  WATER_STOP = '/suspended-user/approval/water/stop', //报停
  WATER_RECOVERY = '/recovery-user/approval/water/recovery', //恢复
  WATER_CANCELLATION = '/abandoned-user/approval/water/stop', //销户/v1.0/customer/admin/abandoned-user/approval/water/stop
  OPEN_WATER = '/open-water/submit', //开通用水审批 /v1.0/customer/admin/open-water/submit
  USE_WATER_NATURE_CHANGE_SUBMIT = '/user-water-usage-change/submit', //用水性质变更提交 /v1.0/customer/admin/user-water-usage-change/submit
  OPEN_WATER_WORK_ORDER = '/open-water/form-data/query', //开通用水工单 /v1.0/customer/admin/open-water/form-data/query
  OPEN_WATER_DETAIL = '/open-water/business-record/query', //开通用水详情 /v1.0/customer/admin/open-water/form-data/query
  METER_CHANGEMETER = '/integrated-business/approval/meter/changeMeter', //更换水表
  METER_PERIOD_CHANGEMETER = '/period-change-meter/', //周期换表
  OTHER_CHANGE = '/integrated-business/approval/other/discountsApply', //优惠申请
  DICT_CHANGE = '/params/ChangeMeterType', //换表原因
  CONFIG_LIST = '/preferential-config/list', //配置列表
  LIST_CODE = '/user/readers', //抄表员
  DEFAULT_METER_READER_LIST = '/integrated-business/getMeterReaderList', // 默认抄表员列表
  RECORD_PATE='/record/page/doing'  //账单分页以出账
}

export const getContactList = (params: object) =>
  defHttp.get({ url: CUSTOMER_ADMIN_API + Api.CONTACT_list, params });

export const getCompanylist = (params: object) =>
  defHttp.get({ url: CUSTOMER_ADMIN_API + Api.COMPANY_LIST, params });

export const postWaterService = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.WATER_SERVICE, data });

export const postWaterStop = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.WATER_STOP, data });

export const postWaterRecovery = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.WATER_RECOVERY, data });

// 销户
export const postWaterCancell = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.WATER_CANCELLATION, data });
// 开通用水
export const postOpenWater = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.OPEN_WATER, data });
export const useWaterNatureChange = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.USE_WATER_NATURE_CHANGE_SUBMIT, data });

// 开通用水工单审批
export const getOpenWater = (approvalBusinessHandlingId: any) =>
  defHttp.get({ url: CUSTOMER_ADMIN_API + Api.OPEN_WATER_WORK_ORDER + '?pkId=' + approvalBusinessHandlingId });

// 开通用水业务记录
  export const getOpenWaterDetail = (approvalBusinessHandlingId: any) =>
  defHttp.get({ url: CUSTOMER_ADMIN_API + Api.OPEN_WATER_DETAIL + '?approvalBusinessId=' + approvalBusinessHandlingId });
// 跟换水表
export const postMeterChange = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.METER_CHANGEMETER, data });
// 周期更换水表
export const postPeriodMeterChange = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.METER_PERIOD_CHANGEMETER + 'create', data });

export const postOtherChange = (data: object) =>
  defHttp.post({ url: CUSTOMER_ADMIN_API + Api.OTHER_CHANGE, data });

export const getDictChange = () => defHttp.get({ url: ADMIN_USER_DICT_API + Api.DICT_CHANGE });

export const getConfigList = (params: object) =>
  defHttp.get({ url: BILLING_ADMIN_API + Api.CONFIG_LIST, params });

export const getListRoleCode = () => defHttp.get({ url: SYS_ADMIN_API + Api.LIST_CODE });

export const getMeterReaderList = (params: { user_id: string }) =>
  defHttp.get({ url: CUSTOMER_ADMIN_API + Api.DEFAULT_METER_READER_LIST, params });

  // 获得账户分页
  export const getRecordPage=(data:object)=>
    defHttp.post({url:BILLING_ADMIN_API+Api.RECORD_PATE,data})
  